import Taro from '@tarojs/taro';
import { View } from '@tarojs/components';
import utils from '@/utils/util'
import './index.scss'

export default class Scan extends Taro.Component {
    constructor(props) {
        super(props);
    }
    config = {
        navigationBarTitleText: '二维码/条码'
    }
    scan() {
        Taro.scanCode({
            onlyFromCamera: false
        }).then((res) => {
            if (res.result && res.result.indexOf('BQ') > -1) {
                Taro.redirectTo({
                    url: '/pages/signin/index?MedicalkitId=' + res.result
                })
            } else {
                utils.showtoast('扫码失败,二维码不符合规范');
            }
        }, (res) => {
            console.log(res);
            utils.showtoast('扫码失败,二维码不符合规范');
        })
    }
    render() {
        return (
            <View className='scan-box mt-16-5'>
                <View className='scan mt-auto' onClick={() => { this.scan() }}>
                </View>
            </View>
        );
    }

}

